package com.learn.thread.demo01;

/**
 * 基于Runnable接口的线程创建和运行。
 * @author Java丶小明
 * @date 2021/6/25 14:37
 */
public class RunnableDemo implements Runnable{
    private int number;
    public RunnableDemo(int number){
        this.number = number;
    }

    @Override
    public void run() {
        for (int i = 1; i < 10; i++) {
            System.out.printf("%s: %d * %d = %d\n",
                    Thread.currentThread().getName(), number, i, i * number);
        }
    }

    public static void main(String[] args) {
        for (int i = 1; i < 10; i++) {
            RunnableDemo runnableDemo = new RunnableDemo(i);
            Thread thread = new Thread(runnableDemo);
            thread.start();
        }
    }
}
